package boot3.mapper;

import boot3.pojo.Notice;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NoticeMapper {
    //根据聊天室的ID获取该聊天室的所有公告
    @Select("select * from notice where chatroom_id=#{chatroom_id}")
    public List<Notice> findAllNotice(String chatroom_id);
    //添加一条公告
    @Insert("insert notice value(#{notice_id},#{notice_content},#{publisher_id},#{publish_time},#{chatroom_id})")
    public Boolean addNotice(String notice_id, String notice_content,
                             String publisher_id, String publish_time, String chatroom_id);
    //获取所有notice
    @Select("select * from notice")
    public List<Notice> findNotices();
    //根据notice_id删除指定的公告
    @Delete("delete from notice where notice_id=#{notice_id}")
    public Boolean deleteNotice(String notice_id);
    //删除指定聊天室中的所有公告
    @Delete("delete from notice where chatroom_id=#{chatroom_id}")
    public Boolean deleteNoticeByChatroomID(String Chatroom_id);
}
